package a07_二叉树;

/**
 * <p>
 * a09_二叉树的最大深度复习3
 * </p>
 *
 * @author flyduck
 * @since 2025/4/8
 */
public class a09_二叉树的最大深度复习3 {
    public int maxDepth(TreeNode root) {
        return getHeight(root);
    }

    private int getHeight(TreeNode node){
        if (node == null) {
            return 0;
        }

        int leftHeight = getHeight(node.left);
        int rightHeight = getHeight(node.right);
        return Math.max(leftHeight, rightHeight) + 1;
    }
}
